<template>
<div>

  <h1>所有商品</h1>
  <table>
    <tr>
      <td>商品</td>
      <td>分类</td>
      <td>操作</td>
      <td>商品id</td>
    </tr>
    <tr v-for="i in list">
      <td>{{i.name}}</td>
      <td>
        <router-link :to="{path:'p6_goods2',query:{id:i.id}}">{{i.fenlei}}</router-link>
        </td>
      <td>
        <button @click="ledt(i.id)">删除</button></td>
      <td><input type="checkbox"></td>
    </tr>
  </table>
  <button @click="get1(i)" v-for="i in num">{{i}}</button>
  <button @click="del_all">一键删除</button>

</div>
</template>

<script>
export default {
  name: "p6_goods",
  data(){
    return{
      list:[],
      num:'',
      flag:false
    }
  },
  methods:{
    get1(i){
      this.$axios.get('users/Sgoods/?cpage='+i)
      .then(i=>{
        this.list = i.data.list
        this.num = i.data.num
      })
    },
    ledt(id){
      this.$axios.delete('users/Sgoods/?id='+id)
      .then(i=>{
        if (i.data.code == 200){
          alert("删除成功")
          this.get1(1)
        }
      })
    },
    del_all(){
      this.$axios.delete('users/')
    }
  },
  mounted() {
    this.get1(1)
  }
}
</script>

<style scoped>

</style>
